package com.lixn.homework.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lixn.homework.mapper.ArticleMapper;
import com.lixn.homework.pojo.Article;
import com.lixn.homework.service.ArticleService;
import com.lixn.homework.util.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("articleService")
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    private ArticleMapper articleMapper;

    @Override
    public PageUtils<Article> findByCondition(int pageNum, int pageSize) throws Exception {
        PageHelper.startPage(pageNum,pageSize);
        List<Article> select = articleMapper.findAll();
        PageInfo<Article> pageInfo = new PageInfo<Article>(select);
        PageUtils<Article> articlePageUtils = new PageUtils<Article>();
        articlePageUtils.setList(select);
        articlePageUtils.setPageInfo(pageInfo);
        return articlePageUtils;
    }
}
